package com.ruoyi.pingan.fymodule.account.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.pingan.fymodule.account.entity.SxoSafetyUser;
import com.ruoyi.pingan.fymodule.account.enums.MemberPropertyEnum;
import com.ruoyi.pingan.fymodule.account.mapper.SxoSafetyUserMapper;
import com.ruoyi.pingan.fymodule.account.service.ISxoSafetyUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
*
* 平安子账号用户 业务层实现
*
* @author wangy
* @since 2025-06-11
*/
@Slf4j
@Service
public class SxoSafetyUserServiceImpl extends ServiceImpl<SxoSafetyUserMapper, SxoSafetyUser> implements ISxoSafetyUserService {


    @Override
    public SxoSafetyUser findUser(String userId, String source) {
        return findUser(userId, source, MemberPropertyEnum.SH.getCode());
    }

    @Override
    public SxoSafetyUser findUser(String userId, String source, String memberProperty) {
        LambdaQueryWrapper<SxoSafetyUser> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(SxoSafetyUser::getSource,source);
        queryWrapper.eq(SxoSafetyUser::getUserId,userId);
        queryWrapper.eq(SxoSafetyUser::getStatus,"0");
        List<SxoSafetyUser> list = this.list(queryWrapper);
        if(!list.isEmpty()){
            return list.get(0);
        }
        return null;
    }
}